<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('Pear Admin 开发平台')"/>
    <link rel="stylesheet" href="admin/css/load.css"/>
    <link rel="stylesheet" href="admin/css/admin.css"/>
    <!-- 主 题 更 换 -->
    <style id="pearadmin-bg-color"></style>
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
<!-- 布 局 框 架 -->
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <!-- 顶 部 左 侧 功 能 -->
        <ul class="layui-nav layui-layout-left">
            <li class="collaspe layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
            <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" title="刷新页面" loading=600></a></li>
        </ul>
        <!-- 顶 部 右 侧 菜 单 -->
        <div id="control" class="layui-layout-control"></div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="http://www.pearadmin.com" class="layui-icon layui-icon-website"></a></li>
            <li class="layui-nav-item">
                <!-- 头 像 -->
                <a href="javascript:;">
                    <img src="" id="avatar" class="avatar">
                    <span th:text="${#authentication.principal.realName}"></span>
                </a>
                <!-- 功 能 菜 单 -->
                <dl class="layui-nav-child">
                    <dd><a user-menu-url="/system/user/center" user-menu-id="5555" user-menu-title="基本资料">基本资料</a></dd>
                    <dd><a href="javascript:void(0);" class="logout">注销登录</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
        </ul>
    </div>
    <!-- 侧 边 区 域 -->
    <div class="layui-side layui-bg-black">
        <!-- 顶 部 图 标 -->
        <div class="layui-logo">
            <img class="logo"></img>
            <span class="title"></span>
        </div>
        <!-- 侧 边 菜 单 -->
        <div class="layui-side-scroll">
            <div id="sideMenu"></div>
        </div>
    </div>
    <div class="layui-body">
        <div id="content"></div>
    </div>
</div>
<!-- 遮 盖 层 -->
<div class="pear-cover"></div>
<!-- 移 动 端 便 捷 操 作 -->
<div class="pear-collasped-pe collaspe"><a href="#" class="layui-icon layui-icon-shrink-right"></a></div>
<!-- 加 载 动 画-->
<div class="loader-main">
    <div class="loader"></div>
</div>
<!-- 依 赖 脚 本 -->
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    layui.use(['admin','jquery','layer'], function () {
        let admin = layui.admin;
        let $ = layui.jquery;
        let layer = layui.layer;

        // 框架初始化时会读取 根目录下 pear.config.yml 文件作为初始化配置
        // 你可以通过 admin.setConfigPath 方法修改配置文件位置
        // 你可以通过 admin.setConfigType 方法修改配置文件类型
        admin.setConfigType("yml");
        admin.setConfigPath("pear.config.yml");

        admin.render();

        $('#avatar').attr("src","/system/file/download/"+[[${session.currentUser.avatar}]]);

        $("body").on("click", ".logout", function() {
            let loader = layer.load();
            $.ajax({
                url: '/logout',
                dataType: 'json',
                type: 'post',
                success: function(result) {
                    layer.close(loader);
                    if (result.success) {
                        layer.msg("注销成功", {
                            icon: 1,
                            time: 1200
                        }, function() {
                            location.href = "/";
                        });
                    }
                }
            })
        })
    })
</script>
</body>
</html>
